package com.j48.entrancegurad.service.impl;

import com.j48.entrancegurad.mapper.CharacterMapper;
import com.j48.entrancegurad.model.A_C;
import com.j48.entrancegurad.model.Character;
import com.j48.entrancegurad.service.ICharacterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class CharacterService implements ICharacterService {

    @Autowired
    private CharacterMapper characterMapper;

    /**
     * 查询角色
     * @param a_c 携带被查询的角色编号
     * @return 角色
     */
    @Override
    public Character select(A_C a_c) {
        Character character=new Character();
        character.setCharacter_id(a_c.getA_c_character_id());
        Character character1=characterMapper.selectById(character);
        return character1;
    }

    /**
     * 按id查询角色
     * @param character
     * @return
     */
    @Override
    public Character selectById(Character character) {
        return characterMapper.selectById(character);
    }

    /**
     * 查询所有角色
     * @return 所有角色
     */
    public ArrayList<Character> selectcharacterall(){
        return characterMapper.selectAll();
    }

    /**
     * 删除角色
     * @param character
     * @return 是否成功
     */
    public int deletecharacter(Character character){
        return characterMapper.delete(character);
    }

    /**
     * 查询角色
     * @param character
     * @return 对象
     */
    public ArrayList<Character> selectcharacter(Character character)
    {
        return characterMapper.selectByName(character);
    }

    /**
     * 按名称查询角色
     * @param character
     * @return
     */
    @Override
    public ArrayList<Character> selectcharacter1(Character character) {
        return characterMapper.selectByName1(character);
    }

    /**
     * 添加角色
     * @param character
     * @return 对象
     */
    public int addcharacter(Character character){
        return characterMapper.insert(character);
    }

    /**
     * 修改角色名字
     * @param character
     * @return
     */
    public int updaterolename(Character character){
        return characterMapper.updaterolename(character);
    }
}
